home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 2010 April / PCWorld0410.iso / pluginy Firefox / 57805 / 57805.xpi / content / statusbar-replacer.js < prev   
Text File  |  2010-01-23  |  6KB  |  145 lines

  1. /* 
  2.            #################################################################
  3.            #   Firefox GUI Minify                                          #
  4.            #################################################################
  5.            #   Author:     Domenico Martella                               #
  6.            #   E-mail:     domenico.martella@alcacoop.it                   #
  7.            #   Date:       2010-01-04                                      #
  8.            #################################################################
  9.            #                                                               #
  10.            #       Copyright (C) 2010  - Alca Soc. Coop. (Lecce, IT)       #
  11.            #       http://www.alcacoop.it                                  #
  12.            #                                                               #
  13.            # This program is free software; you can redistribute           #
  14.            # it and/or modify it under the terms of the GNU General        #
  15.            # Public License as published by the Free Software              #
  16.            # Foundation; either version 3 of the License, or (at your      #
  17.            # option) any later version.                                    #
  18.            #                                                               #
  19.            # This program is distributed in the hope that it will be       #
  20.            # useful, but WITHOUT ANY WARRANTY; without even the            #
  21.            # implied warranty of MERCHANTABILITY or FITNESS FOR A          #
  22.            # PARTICULAR PURPOSE.  See the GNU General Public License       #
  23.            # for more details.                                             #
  24.            #                                                               #
  25.            # You should have received a copy of the GNU General            #
  26.            # Public License along with this program; if not, write to      #
  27.            # the Free Software Foundation, Inc., 59 Temple Place -         #
  28.            # Suite 330, Boston, MA  02111-1307, USA.                       #
  29.            #################################################################
  30. */ 
  31.  
  32.  
  33. var HGBStatusBar = {
  34.  
  35.   origOverLink : null,
  36.   STATE_START : Components.interfaces.nsIWebProgressListener.STATE_START,
  37.   STATE_STOP : Components.interfaces.nsIWebProgressListener.STATE_STOP,
  38.  
  39.   last_timeout_id : null,
  40.  
  41.   init: function() {
  42.     HGBStatusBar._closePopup("hgb-lu");
  43.     HGBStatusBar._closePopup("hgb-pb");
  44.     HGBStatusBar._changeSBColor();
  45.  
  46.     //CUSTOM PROGRESS BAR
  47.     gBrowser.addProgressListener(this.listener, Components.interfaces.nsIWebProgress.NOTIFY_STATE_DOCUMENT);
  48.  
  49.     //CUSTOM LINK URL
  50.     HGBStatusBar.origOverLink = XULBrowserWindow.setOverLink;
  51.  
  52.     XULBrowserWindow.setOverLink = function (link, b){
  53.       if ((!Application.prefs.getValue("gui_minify.statusbar", false))||
  54.           (!Application.prefs.getValue("gui_minify.sblink", false))||
  55.           (HGBExtension.last_state)||
  56.           (HGBExtension.temp_show)){
  57.         HGBStatusBar.origOverLink.call(this, link, b);
  58.         return;
  59.       }
  60.       var str = link;
  61.       if (link.length > 120 ){
  62.         str = link.substring(0,120);
  63.         str += "...";
  64.       }
  65.       if ((link == "")||(!link)||(link == undefined)){
  66.         HGBStatusBar.last_timeout_id = setTimeout(function(){HGBStatusBar._closePopup("hgb-lu")}, 500);
  67.       } else {
  68.         document.getElementById("hgb-linkurl").value = str;
  69.         clearTimeout(HGBStatusBar.last_timeout_id);
  70.         HGBStatusBar._openPopup("hgb-lu");
  71.       }
  72.       HGBStatusBar.origOverLink.call(this, link, b);
  73.     };
  74.   },
  75.  
  76.  
  77.   _changeSBColor : function(){
  78.     var p = document.querySelectorAll("div.div-notify");
  79.     for ( var i = 0; i < p.length; i++ ) {
  80.       p[i].style.backgroundColor = Application.prefs.getValue("gui_minify.sbbgcolor", true);
  81.       p[i].style.color = Application.prefs.getValue("gui_minify.sbcolor", true);
  82.     }
  83.     document.getElementById("border").style.borderColor=Application.prefs.getValue("gui_minify.sbcolor", true);
  84.     document.getElementById("hgb-progressbar").style.backgroundColor=Application.prefs.getValue("gui_minify.sbcolor", true);
  85.   },
  86.  
  87.   _openPopup : function(what){
  88.     var anchor = document.getElementById("hgb-bottom");
  89.     var x = 0;
  90.     var y = anchor.clientHeight - 15;
  91.     if (what=="hgb-pb")
  92.       x = anchor.clientWidth - 160;
  93.  
  94.     var popup = document.getElementById(what);
  95.     popup.openPopup(anchor, "overlap", x, y, false, false);
  96.   },
  97.  
  98.   _closePopup : function(what){
  99.     var popup = document.getElementById(what);
  100.     popup.hidePopup();
  101.   },
  102.  
  103.  
  104.   listener : {
  105.     QueryInterface: function(aIID) {
  106.       if (aIID.equals(Components.interfaces.nsIWebProgressListener) ||
  107.           aIID.equals(Components.interfaces.nsISupportsWeakReference) ||
  108.           aIID.equals(Components.interfaces.nsISupports))
  109.         return this;
  110.       throw Components.results.NS_NOINTERFACE;
  111.     },
  112.  
  113.     onStateChange: function(aWebProgress, aRequest, aFlag, aStatus) {
  114.       //Hide bars if location change and temp_show 
  115.       HGBExtension.tryhide(false);
  116.  
  117.       if ((!Application.prefs.getValue("gui_minify.statusbar", false))||
  118.           (!Application.prefs.getValue("gui_minify.sbprogressbar", false))||
  119.           (HGBExtension.last_state)||
  120.           (HGBExtension.temp_show))
  121.         return;
  122.       if(aFlag & HGBStatusBar.STATE_START) {
  123.         document.getElementById("hgb-progressbar").style.width = 0 + "px";
  124.         HGBStatusBar._openPopup("hgb-pb");
  125.       }
  126.       if(aFlag & HGBStatusBar.STATE_STOP) {
  127.         setTimeout("HGBStatusBar._closePopup('hgb-pb')",200);
  128.       }
  129.     },
  130.  
  131.     onProgressChange: function(aWebProgress, aRequest, curSelf, maxSelf, curTot, maxTot) { 
  132.       if ((!Application.prefs.getValue("gui_minify.statusbar", false))||
  133.           (!Application.prefs.getValue("gui_minify.sbprogressbar", false))||
  134.           (HGBExtension.last_state)||
  135.           (HGBExtension.temp_show))
  136.         return;
  137.       document.getElementById("hgb-progressbar").style.width = (curTot/maxTot*100)*1.48 + "px";
  138.     },
  139.  
  140.     onStatusChange: function(aWebProgress, aRequest, aStatus, aMessage) {},
  141.     onSecurityChange: function(aWebProgress, aRequest, aState) {},
  142.     onLocationChange: function(aProgress, aRequest, aURI) {},
  143.   }
  144. }
  145.